package o;

import android.graphics.PointF;
import android.util.DisplayMetrics;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView.j;
import androidx.recyclerview.widget.RecyclerView.q.c;
import androidx.recyclerview.widget.RecyclerView.q.e;
import androidx.recyclerview.widget.RecyclerView.t;

public class mo extends mu {
    @Nullable
    private mq ˋ;
    @Nullable
    private mq ˎ;

    @Nullable
    public int[] ˏ(@NonNull j jVar, @NonNull View view) {
        int[] iArr = new int[2];
        if (jVar.ʻ()) {
            iArr[0] = ˎ(jVar, view, ˊ(jVar));
        } else {
            iArr[0] = 0;
        }
        if (jVar.ʼ()) {
            iArr[1] = ˎ(jVar, view, ˎ(jVar));
        } else {
            iArr[1] = 0;
        }
        return iArr;
    }

    @Nullable
    public View ॱ(j jVar) {
        if (jVar.ʼ()) {
            return ॱ(jVar, ˎ(jVar));
        }
        if (jVar.ʻ()) {
            return ॱ(jVar, ˊ(jVar));
        }
        return null;
    }

    public int ˏ(j jVar, int i, int i2) {
        Object obj = null;
        int ˌ = jVar.ˌ();
        if (ˌ == 0) {
            return -1;
        }
        View view = null;
        if (jVar.ʼ()) {
            view = ˎ(jVar, ˎ(jVar));
        } else if (jVar.ʻ()) {
            view = ˎ(jVar, ˊ(jVar));
        }
        if (view == null) {
            return -1;
        }
        int ˎ = jVar.ˎ(view);
        if (ˎ == -1) {
            return -1;
        }
        Object obj2;
        if (jVar.ʻ()) {
            obj2 = i > 0 ? 1 : null;
        } else if (i2 > 0) {
            int i3 = 1;
        } else {
            obj2 = null;
        }
        if (jVar instanceof c) {
            PointF ˎ2 = ((c) jVar).ˎ(ˌ - 1);
            if (ˎ2 != null && (ˎ2.x < 0.0f || ˎ2.y < 0.0f)) {
                obj = 1;
            }
        }
        if (obj == null) {
            return obj2 != null ? ˎ + 1 : ˎ;
        } else {
            if (obj2 != null) {
                return ˎ - 1;
            }
            return ˎ;
        }
    }

    protected mh ˋ(j jVar) {
        if (jVar instanceof c) {
            return new mh(this, this.ˏ.getContext()) {
                final /* synthetic */ mo ʻ;

                public void ˋ(View view, t tVar, e eVar) {
                    int[] ˏ = this.ʻ.ˏ(this.ʻ.ˏ.ʻ(), view);
                    int i = ˏ[0];
                    int i2 = ˏ[1];
                    int ˎ = ˎ(Math.max(Math.abs(i), Math.abs(i2)));
                    if (ˎ > 0) {
                        eVar.ˏ(i, i2, ˎ, this.ˎ);
                    }
                }

                protected float ˋ(DisplayMetrics displayMetrics) {
                    return 100.0f / ((float) displayMetrics.densityDpi);
                }

                protected int ˏ(int i) {
                    return Math.min(100, super.ˏ(i));
                }
            };
        }
        return null;
    }

    private int ˎ(@NonNull j jVar, @NonNull View view, mq mqVar) {
        int ˏ;
        int ˊ = (mqVar.ˊ(view) / 2) + mqVar.ˋ(view);
        if (jVar.ʿ()) {
            ˏ = mqVar.ˏ() + (mqVar.ʻ() / 2);
        } else {
            ˏ = mqVar.ॱ() / 2;
        }
        return ˊ - ˏ;
    }

    @Nullable
    private View ॱ(j jVar, mq mqVar) {
        View view = null;
        int ˈ = jVar.ˈ();
        if (ˈ != 0) {
            int ˏ;
            if (jVar.ʿ()) {
                ˏ = mqVar.ˏ() + (mqVar.ʻ() / 2);
            } else {
                ˏ = mqVar.ॱ() / 2;
            }
            int i = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
            int i2 = 0;
            while (i2 < ˈ) {
                View view2;
                View ᐝ = jVar.ᐝ(i2);
                int abs = Math.abs((mqVar.ˋ(ᐝ) + (mqVar.ˊ(ᐝ) / 2)) - ˏ);
                if (abs < i) {
                    view2 = ᐝ;
                } else {
                    abs = i;
                    view2 = view;
                }
                i2++;
                view = view2;
                i = abs;
            }
        }
        return view;
    }

    @Nullable
    private View ˎ(j jVar, mq mqVar) {
        View view = null;
        int ˈ = jVar.ˈ();
        if (ˈ != 0) {
            int i = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
            int i2 = 0;
            while (i2 < ˈ) {
                View view2;
                View ᐝ = jVar.ᐝ(i2);
                int ˋ = mqVar.ˋ(ᐝ);
                if (ˋ < i) {
                    view2 = ᐝ;
                } else {
                    ˋ = i;
                    view2 = view;
                }
                i2++;
                view = view2;
                i = ˋ;
            }
        }
        return view;
    }

    @NonNull
    private mq ˎ(@NonNull j jVar) {
        if (this.ˎ == null || this.ˎ.ॱ != jVar) {
            this.ˎ = mq.ˋ(jVar);
        }
        return this.ˎ;
    }

    @NonNull
    private mq ˊ(@NonNull j jVar) {
        if (this.ˋ == null || this.ˋ.ॱ != jVar) {
            this.ˋ = mq.ˏ(jVar);
        }
        return this.ˋ;
    }
}
